package com.itheima.day20.demo06;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * 7. 已知有一个Map集合,里面存储的是学生的姓名和年龄，内容如下:
 * {张三丰=21, 灭绝师太=38, 柳岩=28, 刘德华=40, 老鬼=36, 王二麻子=38}.
 * 需求: 将年龄大于24的学生姓名，存入到D:\\student.txt中
 */
public class demo07 {
    public static final String DEST = "./homework/src/com/itheima/day20/demo06/student.txt";

    public static void main(String[] args) throws IOException {
        HashMap<String, Integer> hm = new HashMap<>();
        hm.put("张,三", 21);
        hm.put("灭绝师太", 38);
        hm.put("柳岩", 2);
        hm.put("刘华", 40);
        hm.put("老鬼", 36);
        hm.put("王二麻子", 38);
        BufferedWriter bw = new BufferedWriter(new FileWriter(new File(DEST)));
        for (Map.Entry<String, Integer> entry : hm.entrySet()) {
            if (entry.getValue() > 24) {
                bw.write(entry.getKey());
                bw.newLine();
            }
        }
        bw.close();
    }
}
